import Vue from 'vue'
import Router from 'vue-router'
// 其中@符表示src这个目录
import Home from '@/pages/home/Home.vue'
import City from '@/pages/city/City.vue'
import Detail from '@/pages/detail/Detail.vue'

Vue.use(Router)

export default new Router({
  // 路由配置
  routes: [
    {
      path: '/',
      name: 'home',
      component: Home
    },
    // 配置城市选择页面的路由
    {
      path: '/city',
      name: 'City',
      component: City
    },
    //配置详情页路由
    {
      path: '/detail/:id', //这里冒号 + id 的形式就是动态路由
      name: 'Detail',
      component: Detail
    }
  ],
  //解决滚动导致的页面相互影响问题
  scrollBehavior (to, from, savedPosition){
    return {x: 0, y: 0};
  }
})
